<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="款号" class="myform-item">
          <el-input
            v-model="form.type_no"
            placeholder="请输入款号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="RFID编码" class="myform-item">
          <el-input
            v-model="form.number"
            placeholder="请输入RFID编码"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="仓检结果">
          <el-select v-model="form.status" placeholder="请选择">
            <el-option label="不限" value=""> </el-option>
            <el-option label="合格" value="1"> </el-option>
            <el-option label="不合格" value="0"> </el-option>
          </el-select>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button @click="onSearch" type="primary">查询</el-button>
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="款号" align="center" prop="type_no">
      </el-table-column>
      <el-table-column label="RFID编码" align="center" prop="number">
      </el-table-column>
      <el-table-column label="仓检员" align="center" prop="qc_user">
      </el-table-column>
      <el-table-column label="工厂名称" align="center" prop="factory_name">
      </el-table-column>
      <el-table-column label="验货期" align="center" prop="qc_time">
      </el-table-column>
      <el-table-column label="仓检结果" align="center" prop="reason_title">
        <template slot-scope="{ row }">
          {{row.status != 1 ? row.reason_title : "合格"}}
        </template>
      </el-table-column>
      <el-table-column label="问题图片" align="center" prop="qc_img">
        <template slot-scope="{ row }">
          <el-image
            v-if="row.status != 1"
            :src="row.qc_img"
            fit="contain"
            style="width: 200px; height: 200px"
            :preview-src-list="[row.qc_img]"
          ></el-image>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postApiCodeGetQthistorylsit"
    />
  </div>
</template>

<script>
import { postApiCodeGetQthistorylsit } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      date: "",
      form: {
        type_no: "",
        number: "",
        status: "",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postApiCodeGetQthistorylsit(form);
  },
  methods: {
    // 编辑
    onEdit(e) {
      console.log("编辑", e);
      this.detail = e;
      this.dialogVisible = true;
    },
    // 运营列表
    async postApiCodeGetQthistorylsit(data) {
      this.loading = true;
      this.form = data;
      let form = JSON.parse(JSON.stringify(this.form));
      if (form.qc_time) {
        form.qc_time = `${form.qc_time[0]}/${form.qc_time[1]}`;
      }
      postApiCodeGetQthistorylsit(form)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postApiCodeGetQthistorylsit(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
